attachAndroidSurface

fun MapHandle.attachAndroidSurface(descriptor: AndroidSurfaceDescriptor, device: VulkanDeviceHandle? = null, options: RenderSessionAttachOptions): RenderSessionHandle

Creates a session that presents the map to an Android window, with a graphics context that the library creates.

A Vulkan build presents with device, or, when device is null, with a device that the library creates. An OpenGL build uses an EGL context on the default display, and device must be null. Attach with RenderDriverKind.CORE_WORKER.

When the platform destroys the window, such as in SurfaceHolder.Callback.surfaceDestroyed, release the target with RenderSessionHandle.releaseTarget(), or give the session a new window with RenderSessionHandle.setAndroidSurfaceTarget(), without waiting for that to complete. The session keeps its own reference to the window and stays usable for the next window. A frame to the destroyed window finishes with RenderResult.TARGET_NOT_READY, or with RenderResult.RENDERED if the window went away while the frame was presenting.

See mln_map_attach_android_surface in the C API reference.

Errors:

  • Status.INVALID_ARGUMENT when surface has no window, such as after the platform destroyed it.

  • Status.UNSUPPORTED when you created device without VulkanDeviceOptions.presentation.

  • Status.UNSUPPORTED when the GPU or the Vulkan loader can't present.

  • Status.NATIVE_ERROR when the library can't create the graphics context or the window's surface.